package strategy_model

// 定义策略接口
type Strategy interface {
	Execute(int, int) int
}

// 实现具体策略类
type AddStrategy struct{}

func (s *AddStrategy) Execute(a, b int) int {
	return a + b
}

type SubStrategy struct{}

func (s *SubStrategy) Execute(a, b int) int {
	return a - b
}

// 上下文结构体
type Context struct {
	strategy Strategy
}

// 设置策略
func (c *Context) SetStrategy(strategy Strategy) {
	c.strategy = strategy
}

// 执行策略
func (c *Context) ExecuteStrategy(a, b int) int {
	return c.strategy.Execute(a, b)
}
